#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[10005];
	int n,js=0;
	cin>>n;
	
	for (int i=1;i<=n;i++)
	{
		a[i]=i;
	}
	
	for (int i=1;i<=n;i++)
	{
		int r=0;
		while (a[i]>0)
		{
			r=a[i]%10;
			if (r==1) js++;
			a[i]=a[i]/10;
		}
	}
	
	cout<<js<<endl;
	
	return 0;
}